package com.crazy.base.common.core.dto;

import com.crazy.base.common.core.exception.BaseException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result <T>{

    private int code;

    private String msg;

    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<>(0, "success", data);
    }

    public static <T> Result<T> of(BaseException e) {
        return new Result<>(e.getCode(), e.getMsg(), null);
    }
}
